package com.office.meeting.manage.controller;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.websocket.server.PathParam;

import io.swagger.annotations.Api;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.office.common.annotation.Log;
import com.office.common.core.controller.BaseController;
import com.office.common.core.domain.AjaxResult;
import com.office.common.enums.BusinessType;
import com.office.meeting.manage.domain.ConferenceInvitation;
import com.office.meeting.manage.service.IConferenceInvitationService;
import com.office.common.utils.poi.ExcelUtil;
import com.office.common.core.page.TableDataInfo;

/**
 * 我的会议管理Controller
 *
 * @author ruoyi
 * @date 2025-05-16
 */
@RestController
@RequestMapping("/meeting/manage")
public class ConferenceInvitationController extends BaseController {

    @Resource
    private IConferenceInvitationService conferenceInvitationService;

    /**
     * 查询我的会议管理列表
     */
    @PreAuthorize("@ss.hasPermi('meeting:manage:list')")
    @GetMapping("/list")
    public TableDataInfo list(ConferenceInvitation conferenceInvitation) {
        startPage();
        List<ConferenceInvitation> list = conferenceInvitationService.selectConferenceInvitationList(conferenceInvitation);
        return getDataTable(list);
    }

    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        ConferenceInvitation conferenceInvitation = conferenceInvitationService.seletcMeetingById(id);
        return AjaxResult.success(conferenceInvitation);
    }

    /**
     * 同意会议
     */
    @Log(title = "同意会议", businessType = BusinessType.UPDATE)
    @PutMapping("/agree/{ids}")
    public AjaxResult agree(@PathVariable List<Long> ids) {
        return AjaxResult.success(conferenceInvitationService.updateConferenceInvitation(ids));
    }

    /**
     * 拒绝会议
     */
    @Log(title = "拒绝会议", businessType = BusinessType.UPDATE)
    @PutMapping("/refused/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids, @PathParam("reason") String reason) {
        return AjaxResult.success(conferenceInvitationService.updateConferenceInvitationByIds(ids, reason));
    }

    /**
     * 导出我的会议管理列表
     */
    @Log(title = "我的会议管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ConferenceInvitation conferenceInvitation)
    {
        List<ConferenceInvitation> list = conferenceInvitationService.selectConferenceInvitationList(conferenceInvitation);
        ExcelUtil<ConferenceInvitation> util = new ExcelUtil<ConferenceInvitation>(ConferenceInvitation.class);
        util.exportExcel(response, list, "我的会议管理数据");
    }

}
